<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>素材编辑</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="/front/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/front/hAdmin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/front/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">

    <style>
        .droppable-active {
            background-color: #ffe !important;
        }

        .tools a {
            cursor: pointer;
            font-size: 80%;
        }

        .form-body .col-md-6,
        .form-body .col-md-12 {
            min-height: 400px;
        }

        .draggable {
            cursor: move;
        }
    </style>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">

    <div class="row">
        <div class="col-sm-5">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>详情</h5>
                </div>
                <div class="ibox-content">
                    <div class="alert alert-info">
                        友情提示！
                    </div>
                    <form id='form' role="form" class="form-horizontal" action="/front/source-pic/update" method="post" enctype="multipart/form-data">
                        <div class="form-group draggable ui-draggable {{$errors->first('source_pic_id')!=""?'has-error':''}}">
                            <label class="col-sm-3 control-label">素材Id：</label>
                            <div class="col-sm-5" >
                                <input type="text"  name="source_pic_id" readonly class="form-control width-100" value="{{isset($source_pic->source_pic_id)?$source_pic->source_pic_id:''}}">
                            </div>
                            <div class="col-sm-4">
                                <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('source_pic_id')}}</div>
                            </div>
                        </div>
                        <div class="form-group draggable ui-draggable {{$errors->first('name')!=""?'has-error':''}}">
                            <label class="col-sm-3 control-label">素材名称：</label>
                            <div class="col-sm-4">
                                <input type="text" name="name"   class="form-control" value={{isset($source_pic->name)?$source_pic->name:''}}>
                            </div>
                            <div class="col-sm-4">
                                <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('name')}}</div>
                            </div>
                        </div>
                        <div class="form-group draggable ui-draggable">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="col-sm-4">
                                <img alt="image" class="img-responsive" src="{{isset($source_pic->small_image)?$source_pic->small_image:''}}">
                            </div>
                        </div>
                        <div class="form-group draggable ui-draggable {{$errors->first('price')!=""?'has-error':''}}">
                            <label class="col-sm-3 control-label">售价：</label>
                            <div class="col-sm-4">
                                <input type="number" name="price" step=0.01 min=0  class="form-control" value={{isset($source_pic->price)?$source_pic->price:0}}>
                            </div>
                            <div class="col-sm-4">
                                <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('price')}}</div>
                            </div>
                        </div>
                        <div class="form-group draggable ui-draggable">
                            <label class="col-sm-3 control-label">下架时间类型：</label>
                            <div class="col-sm-4" style="width: 60px">
                                <select id="sel_limited_time_type" name="limited_time_type">
                                    <option value="unlimited_time">不限</option>
                                    <option value="limited_time">限时</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group limited_time {{$errors->first('end_time')!=""?'has-error':''}}" style="display: none">
                            <label class="col-sm-2 control-label">下架时间：</label>
                            <div class="col-sm-10">
                                <input class="form-control layer-date" name="end_time" value="{{(isset($source_pic->end_time)&&!empty($source_pic->end_time))?date('Y-m-d H:i:s',$source_pic->end_time):date('Y-m-d H:i:s',time())}}" placeholder="YYYY-MM-DD hh:mm:ss" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                                <label class="laydate-icon"></label>
                            </div>
                            <div class="col-sm-4">
                                <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('price')}}</div>
                            </div>
                        </div>
                        <div class="form-group draggable">
                            <div class="col-sm-12 col-sm-offset-3">
                                <button class="btn btn-primary" type="button" id="save">提交审核</button>
                            </div>
                        </div>
                    </form>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>

</div>

<!-- 全局js -->
<script src="/front/hAdmin/js/jquery.min.js?v=2.1.4"></script>
<script src="/front/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="/front/hAdmin/js/content.js?v=1.0.0"></script>

<!-- jQuery UI -->
<script src="/front/hAdmin/js/jquery-ui-1.10.4.min.js"></script>
<script src="/front/hAdmin/js/plugins/layer/laydate/laydate.js"></script>
<script src="/js/dist/sweetalert-dev.js"></script>
<link rel="stylesheet" href="/js/dist/sweetalert.css">
<script type="application/javascript">
    $(function () {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $("#my-source-pic-manage").parent().addClass("active");
        $("#my-source-pic-manage").parent().siblings().removeClass("active");
        $('#sel_limited_time_type').change(function() {
            var sel_limited_time_type=$(this).val();
            if(sel_limited_time_type=='limited_time'){
                $('.limited_time').show();
            }else {
                $('.limited_time').hide();
            }
            console.log('sel_limited_time_type:'+sel_limited_time_type);
        });
        var save_state=1;
        $('#save').click(function() {
            if(save_state==0){
                return false;
            }
            save_state==0;
            $.ajax({
                type: "POST",
                cache: true,
                url: "/front/source-pic/update",
                data:$('#form').serialize(),
                success: function (msg) {
                    if(msg.state==1){
                        swal({title: "保存成功！", text: "",type: "success", timer:1000 });
                    }else {
                        swal({title: msg.message, text: "",type: "error", timer:1000 });
                    }
                }, error: function () {
                    swal({title: "系统繁忙！", text: "",type: "error", timer:1000 })
                }
            });
            save_state==1;
        });
    })
    //外部js调用
    laydate({
        elem: '#hello', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
</script>
</body>

</html>
